<template>
  <el-header class="header">
    <el-col :span="6"><span class="headTitle" @click="quit">运维管控系统</span></el-col>
<!--    <el-col :span="1" :offset="17"><span :offset="6" class="headTitle" type="button" style="margin-right: 0px" @click="goIndex"><i class="el-icon-s-home"></i></span></el-col>-->

    <el-col :span="1" :offset="3" >
      <el-button type="primary" size="mini" @click="goStorage1">存储1</el-button>
    </el-col>

    <el-col :span="1" :offset="5" >
      <el-button type="primary" size="mini" @click="goStorage2">存储2</el-button>
    </el-col>

    <el-col :span="1" :offset="5" >
      <el-button type="primary" size="mini" @click="goPgy">云平台</el-button>
    </el-col>
    <!--    <div>-->
<!--      <el-dialog title="外部地址" :visible.sync="dialogUrlVisible" width="800px"  >-->
<!--        <el-input type="text"  v-model="inputValue" @keypress.native.enter="confrim" ></el-input>-->
<!--        <el-button class="btn" @click="confrim()">确定</el-button>-->
<!--        <el-button class="btn" @click="dialogUrlVisible = false">取消</el-button>-->
<!--      </el-dialog>-->
<!--    </div>-->
  </el-header>


</template>
<script>

  import {outside_url} from "../../../static/config.js"

export default {
  data() {
    return {
      inputValue: '',
      // dialogUrlVisible: false,
    };
  },
  methods: {
    getDateAndTime: function() {
      var date = new Date();
      var year = date.getFullYear(); //当前年份
      var month = date.getMonth(); //当前月份
      var day = date.getDate(); //天
      var hours = date.getHours(); //小时
      var minute = date.getMinutes(); //分
      var second = date.getSeconds(); //秒
      let num = 0;
      hours = hours >= 10 ? (num = hours) : (num = "0" + hours);
      minute = minute >= 10 ? (num = minute) : (num = "0" + minute);
      second = second >= 10 ? (num = second) : (num = "0" + second);
      this.dateTime = year + "/" + (month + 1) + "/" + day;
      this.time = hours + ":" + minute + ":" + second;
    },
    goIndex() {
      if(outside_url !== null && outside_url !== ''){
        window.location.href = outside_url
      } else{
        this.$message({
          message: '跳转地址为空',
          duration: 1500,
          type: 'warning'
        })
      }
    },
    goStorage1() {
      window.location.href = "https://9.17.5.212:8088"
    },
    goStorage2() {
      window.location.href = "https://9.17.5.210:8088"
    },
    goPgy() {
      window.location.href = "http://9.17.4.69:8663"
    },
    quit() {
      // 清空session
      let pwd = sessionStorage.getItem("username");
      sessionStorage.clear();

      this.$axios({
        method: "post",
        url: '/user/logout.action',
        data: {
          username: pwd,
        }
      }).then(res=>{
        this.$message({
          message: '退出成功',
          type: 'success'
        })
      }).catch((err)=>{
        this.$message({
          message: '退出异常',
          type: 'error'
        })
        console.log(err);
      })
      this.$router.push("/");
      // this.$confirm('确定要退出系统吗?', '提示', {
      //   cancelButtonText: '取消',
      //   confirmButtonText: '确定',
      //   type: 'warning'
      // }).then(() => {
      //   // 清空session
      //   sessionStorage.clear();
      //
      //   this.$router.push("/");
      // }).catch(() => {
      // });
    },
    // confrim(){
    //   if (!this.inputValue | this.inputValue!=''){
    //     confirm("输入地址不能为空!!!")
    //   }else{
    //     window.location.href ='https://' + this.inputValue
    //     this.inputValue=''
    //   }
    // },
  },
  activated() {

  },
  mounted() {
      setInterval(this.getDateAndTime, 1000);
  },
};
</script>
<style>
.header {
  background: #466a9e;
  top: 0;
  position: fixed;
  left: 0;
  right: 0;
  z-index: 9;
}
</style>
